Source:NetHack 3.2.0/tradstdc.h
Below is the full text to tradstdc.h from the source code of NetHack 3.2.0. To link to a particular line, write [[NetHack 3.2.0/tradstdc.h#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)tradstdc.h 3.2 93/05/30 */ 2. /* Copyright © Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #ifndef TRADSTDC_H 6. #define TRADSTDC_H 7. 8. #if defined(DUMB) && !defined(NOVOID) 9. #define NOVOID 10. #endif 11. 12. #ifdef NOVOID 13. #define void int 14. #endif 15. 16. /* 17. * Borland C provides enough ANSI C compatibility in its Borland C++ 18. * mode to warrant this. But it does not set __STDC__ unless it compiles 19. * in its ANSI keywords only mode, which prevents use of and 20. * far pointer use. 21. */ 22. #if (defined(__STDC__) || defined(__TURBOC__)) && !defined(NOTSTDC) 23. #define NHSTDC 24. #endif 25. 26. #if defined(ultrix) && defined(__STDC__) && !defined(__LANGUAGE_C) 27. /* Ultrix seems to be in a constant state of flux. This check attempts to 28. * set up ansi compatibility if it wasn't set up correctly by the compiler. 29. */ 30. #ifdef mips 31. #define __mips mips 32. #endif 33. 34. #ifdef LANGUAGE_C 35. #define __LANGUAGE_C LANGUAGE_C 36. #endif 37. 38. #endif 39. 40. /* 41. * ANSI X3J11 detection. 42. * Makes substitutes for compatibility with the old C standard. 43. */ 44. 45. /* Decide how to handle variable parameter lists: 46. * USE_STDARG means use the ANSI facilities (only ANSI compilers 47. * should do this, and only if the library supports it). 48. * USE_VARARGS means use the facilities. Again, this should only 49. * be done if the library supports it. ANSI is *not* required for this. 50. * Otherwise, the kludgy old methods are used. 51. * The defaults are USE_STDARG for ANSI compilers, and USE_OLDARGS for 52. * others. 53. */ 54. 55. /* #define USE_VARARGS /* use instead of */ 56. /* #define USE_OLDARGS /* don't use any variable argument facilites */ 57. 58. #if defined(apollo) /* Apollos have stdarg(3) but not stdarg.h */ 59. # define USE_VARARGS 60. #endif 61. 62. #if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(MAC) 63. # if !defined(USE_VARARGS) && !defined(USE_OLDARGS) && !defined(USE_STDARG) 64. # define USE_STDARG 65. # endif 66. #endif 67. 68. #ifdef NEED_VARARGS /* only define these if necessary */ 69. #ifdef USE_STDARG 70. #include 71. # define VA_DECL(typ1,var1) (typ1 var1, ...) { va_list the_args; 72. # define VA_DECL2(typ1,var1,typ2,var2) \ 73. (typ1 var1, typ2 var2, ...) { va_list the_args; 74. # define VA_INIT(var1,typ1) 75. # define VA_NEXT(var1,typ1) var1 = va_arg(the_args, typ1) 76. # define VA_ARGS the_args 77. # define VA_START(x) va_start(the_args, x) 78. # define VA_END() va_end(the_args) 79. # if defined(ULTRIX_PROTO) && !defined(_VA_LIST_) 80. # define _VA_LIST_ /* prevents multiple def in stdio.h */ 81. # endif 82. #else 83. # ifdef USE_VARARGS 84. #include 85. # define VA_DECL(typ1,var1) (va_alist) va_dcl {\ 86. va_list the_args; typ1 var1; 87. # define VA_DECL2(typ1,var1,typ2,var2) (va_alist) va_dcl {\ 88. va_list the_args; typ1 var1; typ2 var2; 89. # define VA_ARGS the_args 90. # define VA_START(x) va_start(the_args) 91. # define VA_INIT(var1,typ1) var1 = va_arg(the_args, typ1) 92. # define VA_NEXT(var1,typ1) var1 = va_arg(the_args,typ1) 93. # define VA_END() va_end(the_args) 94. # else 95. # define VA_ARGS arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9 96. # define VA_DECL(typ1,var1) (var1,VA_ARGS) typ1 var1; \ 97. char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; { 98. # define VA_DECL2(typ1,var1,typ2,var2) (var1,var2,VA_ARGS) \ 99. typ1 var1; typ2 var2;\ 100. char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; { 101. # define VA_START(x) 102. # define VA_INIT(var1,typ1) 103. # define VA_END() 104. # endif 105. #endif 106. #endif /* NEED_VARARGS */ 107. 108. #if defined(NHSTDC) || defined(MSDOS) || defined(MAC) || defined(ULTRIX_PROTO) 109. 110. /* 111. * Used for robust ANSI parameter forward declarations: 112. * int VDECL(sprintf, (char *, const char *, ...)); 113. * 114. * NDECL() is used for functions with zero arguments; 115. * FDECL() is used for functions with a fixed number of arguments; 116. * VDECL() is used for functions with a variable number of arguments. 117. * Separate macros are needed because ANSI will mix old-style declarations 118. * with prototypes, except in the case of varargs, and the OVERLAY-specific 119. * trampoli.* mechanism conflicts with the ANSI <> syntax. 120. */ 121. 122. # define NDECL(f) f(void) /* overridden later if USE_TRAMPOLI set */ 123. 124. # define FDECL(f,p) f p 125. 126. # if defined(MSDOS) || defined(USE_STDARG) 127. # define VDECL(f,p) f p 128. # else 129. # define VDECL(f,p) f() 130. # endif 131. 132. /* generic pointer, always a macro; genericptr_t is usually a typedef */ 133. # define genericptr void * 134. 135. # if (defined(ULTRIX_PROTO) && !defined(__GNUC__)) || defined(OS2_CSET2) 136. /* Cover for Ultrix on a DECstation with 2.0 compiler, which coredumps on 137. * typedef void * genericptr_t; 138. * extern void a(void(*)(int, genericptr_t)); 139. * Using the #define is OK for other compiler versions too. 140. */ 141. /* And IBM CSet/2. The redeclaration of free hoses the compile. */ 142. # define genericptr_t genericptr 143. # else 144. # if !defined(NHSTDC) && !defined(MAC) 145. # define const 146. # define signed 147. # define volatile 148. # endif 149. # endif 150. 151. /* 152. * Suppress `const' if necessary and not handled elsewhere. 153. * Don't use `#if defined(xxx) && !defined(const)' 154. * because some compilers choke on `defined(const)'. 155. * This has been observed with Lattice, MPW, and High C. 156. */ 157. # if (defined(ULTRIX_PROTO) && !defined(NHSTDC)) || defined(apollo) 158. /* the system header files don't use `const' properly */ 159. # ifndef const 160. # define const 161. # endif 162. # endif 163. 164. #else /* NHSTDC */ /* a "traditional" C compiler */ 165. 166. # define NDECL(f) f() 167. # define FDECL(f,p) f() 168. # define VDECL(f,p) f() 169. 170. # if defined(AMIGA) || defined(HPUX) || defined(POSIX_TYPES) || defined(__DECC) 171. # define genericptr void * 172. # endif 173. # ifndef genericptr 174. # define genericptr char * 175. # endif 176. 177. /* 178. * Traditional C compilers don't have "signed", "const", or "volatile". 179. */ 180. # define signed 181. # define const 182. # define volatile 183. 184. #endif /* NHSTDC */ 185. 186. 187. #ifndef genericptr_t 188. typedef genericptr genericptr_t; /* (void *) or (char *) */ 189. #endif 190. 191. 192. /* 193. * According to ANSI, prototypes for old-style declarations must widen the 194. * arguments to int. However, the MSDOS compilers accept shorter arguments 195. * (char, short, etc.) in prototypes and do typechecking with them. Therefore 196. * this mess to allow the better typechecking while also allowing some 197. * prototypes for the ANSI compilers so people quit trying to fix the 198. * prototypes to match the standard and thus lose the typechecking. 199. */ 200. #if defined(MSDOS) && !defined(__GO32__) 201. #define UNWIDENED_PROTOTYPES 202. #endif 203. #if defined(AMIGA) && !defined(AZTEC_50) 204. #define UNWIDENED_PROTOTYPES 205. #endif 206. #if defined(applec) 207. #define UNWIDENED_PROTOTYPES 208. #endif 209. #if defined(WIN32) 210. #define UNWIDENED_PROTOTYPES 211. #endif 212. 213. #if defined(ULTRIX_PROTO) && defined(ULTRIX_CC20) 214. #define UNWIDENED_PROTOTYPES 215. #endif 216. #if defined(apollo) 217. #define UNWIDENED_PROTOTYPES 218. #endif 219. 220. #ifndef UNWIDENED_PROTOTYPES 221. # if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(THINK_C) 222. # define WIDENED_PROTOTYPES 223. # endif 224. #endif 225. 226. #if 0 227. /* The problem below is still the case through 4.0.5F, but the suggested 228. * compiler flags in the Makefiles suppress the nasty messages, so we don't 229. * need to be quite so drastic. 230. */ 231. #if defined(__sgi) && !defined(__GNUC__) 232. /* 233. * As of IRIX 4.0.1, /bin/cc claims to be an ANSI compiler, but it thinks 234. * it's impossible for a prototype to match an old-style definition with 235. * unwidened argument types. Thus, we have to turn off all NetHack 236. * prototypes, and avoid declaring several system functions, since the system 237. * include files have prototypes and the compiler also complains that 238. * prototyped and unprototyped declarations don't match. 239. */ 240. # undef NDECL 241. # undef FDECL 242. # undef VDECL 243. # define NDECL(f) f() 244. # define FDECL(f,p) f() 245. # define VDECL(f,p) f() 246. #endif 247. #endif 248. 249. 250. /* MetaWare High-C defaults to unsigned chars */ 251. /* AIX 3.2 needs this also */ 252. #if defined(__HC__) || defined(_AIX32) 253. # undef signed 254. #endif 255. 256. 257. /* 258. * Allow gcc2 to check parameters of printf-like calls with -Wformat; 259. * append this to a prototype declaration (see pline() in extern.h). 260. */ 261. #ifdef __GNUC__ 262. # if __GNUC__ >= 2 263. #define PRINTF_F(f,v) __attribute__ ((format (printf, f, v))) 264. # endif 265. #endif 266. #ifndef PRINTF_F 267. #define PRINTF_F(f,v) 268. #endif 269. 270. #endif /* TRADSTDC_H */ tradstdc.h